package com.my.chapter13;



import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class practice19 {
    private static final String Identifier =
            "[$A-Za-z_][$A-Za-z_0-9]*";
    private static final String ClassOrInterfaceType =
            Identifier + "(?:\\." + Identifier + ")*";
    static final String CU_REP_REGEX =
            "class\\s+" + Identifier +
                    "|extends\\s+" + ClassOrInterfaceType +
                    "|new\\s+" + ClassOrInterfaceType;

    public static void main(String[] args) throws Exception{
        if(args.length < 1) {
            System.out.println(
                    "Usage: java E19_JClassUsageReporter file");
            System.exit(0);
        }
        //String src = TextFile.read(args[0]);
        String src = "";
        // Prune away comments ...
        src = src.replaceAll(
                JCommentExtractor.CMNT_EXT_REGEX, "");
        // Prune away string literals ...
        src = src.replaceAll(
                practice18.STR_EXT_REGEX, "");
        Pattern p = Pattern.compile(CU_REP_REGEX);
        Matcher m = p.matcher(src);
        while(m.find())
            System.out.println(m.group());
    }
}
